<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>下载任务</title>
    <link rel="stylesheet" href="./src/bootstrap/css/bootstrap.min.css">
    <style>
        textarea { min-height: 320px; }
        pre { padding: 6px 12px; min-height:400px; }
        .string { color: #92278f; }
        .number { color: #25aae2; }
        .boolean { color: #f0ad4e; }
        .null { color: #d9534f; }
        .key { color: #4cae4c; }
    </style>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        
        <div class="col-md-12">
            <h3>上传</h3>
            <hr>
        </div>
        <div class="col-md-12">
            <form action="http://127.0.0.1:8882/admin/user/permit/add" method="POST" enctype="multipart/form-data">
                <div class="form-group">
                    <label>文件路径</label>
                    <input type="file" name="file" class="form-control">
                </div>
                <button type="submit" class="btn btn-success">提交</button>
            </form>
        </div>
        <div class="col-md-12">
            <h3>信息</h3>
            <h4 class="message"></h4>
        </div>
    </div>
</div> 
</body>
<script src="./src/axios.min.js"></script>
<script src="./src/config.js"></script>
<script>

    var AppApi = window.AppApi;
    function download () {

        var downloaddir = document.getElementsByName('downloaddir')[0].value;

        var config = {
            method: 'post',
            url: AppApi.download,
            data: {
                downloaddir: downloaddir,
            },
            headers: window.AppHeader,
        }

        curl(config, function ( dd ){
            var content = dd.data;
            console.log(content);
            document.getElementsByClassName('message')[0].innerHTML = content.msg;
            // 定时器取消消息
            setTimeout(function () {
                document.getElementsByClassName('message')[0].innerHTML = '';
            }, 2000);
        });

    }

    // 发送 CURL 请求
    function curl ( config , callback ) {
        axios(config).then(callback).catch(function (error) {
            console.log(error);
        });
    }

</script>
</html>